<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        a{
            text-decoration: none;
            color:inherit
        }
        div.container{
            width: 1080px;
            height: 420px;
            overflow: hidden;
        }
        div.num {
            width:400px;
            height:50px;
            position: relative;
            top:-55px;
            left:350px;
        }
        div.sub{
            width:50px;
            height:50px;
            border:1px solid ;
            text-align: center;
            line-height: 50px;
            color:white;
            float:left;
            cursor: pointer;
        }
       
    </style>
</head>
<body onload="play()">
    <div class="container">
        <div style="display: block;"><img src="./images/1.jpg" alt=""></div>
        <div style="display: none;"><img src="./images/2.jpg" alt=""></div>
        <div style="display: none;"><img src="./images/3.jpg" alt=""></div>
        <div style="display: none;"><img src="./images/4.jpg" alt=""></div>  
    </div>
    <div class="num">
        <div class="sub"><a href="#">1</a></div>
        <div class="sub"><a href="#">2</a></div>
        <div class="sub"><a href="#">3</a></div>
        <div class="sub"><a href="#">4</a></div>
    </div>

    <script>
        let index = 0 ;
        let imageDivs = document.querySelector(".container").children;
        let numDivs = document.querySelectorAll(".sub");
        function play() {
            if(index>=imageDivs.length) {
                index = 0 ;
            }
            hideAllDivs();
            imageDivs[index].style.display = "block";
            numDivs[index].style.background= "deeppink"
            index++ ;
        }
        function hideAllDivs(){
            for(let i = 0 ;i<imageDivs.length;i++) {
                imageDivs[i].style.display = "none";
                numDivs[i].style.background= "transparent"
            }
        }
        setInterval(play,1000);
    </script>
</body>
</html>